package com.org.controller.mgr;

import com.org.form.AgreementInfoForm;
import com.org.service.AgreementMgrService;
import com.org.util.JsonUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

/**
 * author: vane.Q
 * date: 2022/10/19 14:53
 */
@RestController
@RequestMapping("/mgr")
public class AgreementMgrController {

    @Autowired
    private AgreementMgrService agreementMgrService;

    /**
     * 协议类型接口
     * @return
     * @throws IOException
     */
    @PostMapping("/typeList")
    public String category() throws IOException {
        return JsonUtils.objectToJsonString(agreementMgrService.category());
    }

    /**
     * 协议新增接口
     * @param form
     * @throws IOException
     */
    @PostMapping("/addAgreement")
    public String addAgreement(@Validated(value = AgreementInfoForm.AddAgreement.class) AgreementInfoForm form) {
        return JsonUtils.objectToJsonString(agreementMgrService.addAgreement(form));
    }
}
